package com.sumainfor.wx.tenant.controller;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.wx.tenant.feign.MarketFeignClient;
import com.sumainfor.wx.tenant.feign.OperationsFeignClient;
import com.sumainfor.wx.tenant.service.impl.PayBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 功能描述:
 * 账单相关
 * @Auther: zhlu
 * @Date: 2019/4/28 16:08
 * @Description:
 */
@RestController
@RequestMapping("/paybill")
public class PayBillController {

    @Autowired
    MarketFeignClient MarketFeignClient;

    @Autowired
    PayBillService PayBillService;

    @Autowired
    OperationsFeignClient OperationsFeignClient;

    /**
     * 功能描述: 
     * 根据账单资料房源资料获取房源信息
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/4/28 16:23
     */
    @GetMapping("/getTrenantBillHousing")
    public JsonResult getTrenantBillHousing(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"BiId"})){
            result.putFailed("BiId不能为空！");
            return  result;
        }
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"TenId"})){
            result.putFailed("TenId不能为空！");
            return  result;
        }
        return result.put(PayBillService.getTrenantBillHousing(params));
    }

    /**
     * 功能描述: 
     * 根据账单资料生成账单支付信息
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/4/29 20:31
     */
    @PostMapping("/setPayWechatBill")
    public JsonResult setPayWechatBill(@RequestBody Map<String,Object>params){
        return OperationsFeignClient.setPayWechatBill(params);
    }

    /**
     * 功能描述:
     * 微信账单完成支付验证
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/4/30 10:31
     */
    @PostMapping("/PayWechatBillCensor")
    public JsonResult PayWechatBillCensor(@RequestBody Map<String,Object>params){
        return  OperationsFeignClient.PayWechatBillCensor(params);
    }

}
